import "./assets/main.css";

import { createApp } from "vue";
import { createPinia } from "pinia";

import { renderWithQiankun, qiankunWindow } from "vite-plugin-qiankun/dist/helper.js";
import App from "./App.vue";
import router from "./router";

// app;
// app.use(router);

// app.mount("#sub-container");

let app: any;
if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  createApp(App).use(router).mount("#Investment-container");
} else {
  renderWithQiankun({
    mount(props: any) {
      // 传递的值可以获取到了
      app = createApp(App);

      app.use(router).use(createPinia());
      app.mount(
        props.container
          ? props.container.querySelector("#Investment-container")
          : document.getElementById("Investment-container")
      );

      window.$props = props; // 将props存储到全局变量中，方便其他组件访问
      //   qiankunWindow.$props.mainRouter.push("/Investment/about");
    },
    bootstrap() {
      console.log("--bootstrap");
    },
    update(props: any) {
      console.log("--update", props);
    },
    unmount() {
      console.log("--unmount");
      app?.unmount();
    },
  });
}
